package com.itboye.mengwu.data.presenter;

import java.util.List;
import java.util.Observer;

import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.core.object.BasePresenter;
import com.itboye.core.object.ResultEntity;
import com.itboye.mengwu.app.ui.main.MainPresenter;
import com.itboye.mengwu.data.interfaces.IAddGoods;
import com.itboye.mengwu.data.model.GoodsListModel;
import com.itboye.mengwu.data.model.GoodsListModel.GoodsList;
import com.itboye.mengwu.data.repository.AddGoodsRepository;

public class AddGoodsPresenter extends BasePresenter implements
		IAddGoods<GoodsListModel> {
	
	//查询商品（不分页）
	public static final String AddGoods_success = MainPresenter.class.getName()
			+ "_AddGoods_success";
	public static final String AddGoods_fail = MainPresenter.class.getName()
			+ "_AddGoods_fail";

	//添加收藏
	public static final String AddGoodsToCollection_success = MainPresenter.class.getName()
			+ "_AddGoodsCollection_success";
	public static final String AddGoodsToCollection_fail = MainPresenter.class.getName()
			+ "_AddGoodsCollection_fail";
	
	
	
	
	public static final String Mytiezi_success = MainPresenter.class.getName()
			+ "_Mytiezi_success";
	public static final String Mytiezi_fail = MainPresenter.class.getName()
			+ "_Mytiezi_fail";
	
	//收藏商品查询（分页）BY_Product_getFavorites
	public static final String CollecteGoodsQuery_success = MainPresenter.class.getName()
			+ "_CollecteGoodsQuery_success";
	public static final String CollectGoodsQuery_fail = MainPresenter.class.getName()
			+ "_CollecteGoodsQuery_fail";
	
	

	//我的帖子14.1
	public static final String MytieZi_success = MainPresenter.class.getName()
			+ "_MytieZi_success";
	public static final String MytieZi = MainPresenter.class.getName()
			+ "_MytieZi_fail";
	public AddGoodsPresenter(Observer observer) {
		super(observer);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void add(GoodsListModel model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void delete(GoodsListModel model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(GoodsListModel model) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void getInfo(GoodsListModel model) {
		IAddGoods<GoodsListModel> addGoods = new AddGoodsRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(AddGoods_success);
						AddGoodsPresenter.this.setChanged();
						AddGoodsPresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(AddGoods_fail);
						AddGoodsPresenter.this.setChanged();
						AddGoodsPresenter.this.notifyObservers(result);

					}
				});
		addGoods.getInfo(model);//("", "", "", "");

	}

	@Override
	public List<GoodsListModel> query(GoodsListModel model) {
		
		return null;
	}

	@Override
	public void addCollection(String uid, String pid, int values) {
		// TODO Auto-generated method stub
		IAddGoods<GoodsListModel> addGoods = new AddGoodsRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(AddGoodsToCollection_success);
						AddGoodsPresenter.this.setChanged();
						AddGoodsPresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(AddGoodsToCollection_fail);
						AddGoodsPresenter.this.setChanged();
						AddGoodsPresenter.this.notifyObservers(result);

					}
				});
		addGoods.addCollection(uid, pid, values);//(model);
	}

	@Override
	public void queryCollectionGoods(String uid, String pageNo, String pageSize) {
		// TODO Auto-generated method stub
		IAddGoods<GoodsListModel> addGoods = new AddGoodsRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(CollecteGoodsQuery_success);
						AddGoodsPresenter.this.setChanged();
						AddGoodsPresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(CollectGoodsQuery_fail);
						AddGoodsPresenter.this.setChanged();
						AddGoodsPresenter.this.notifyObservers(result);

					}
				});
		addGoods.queryCollectionGoods(uid, pageNo, pageSize);
	}

	@Override
	public void MyTieziShouCang(String uid, String tid, int favorite_value) {
		// TODO Auto-generated method stub
		IAddGoods<GoodsListModel> addGoods = new AddGoodsRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(Mytiezi_success);
						AddGoodsPresenter.this.setChanged();
						AddGoodsPresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(Mytiezi_fail);
						AddGoodsPresenter.this.setChanged();
						AddGoodsPresenter.this.notifyObservers(result);

					}
				});
		addGoods.MyTieziShouCang(uid, tid, favorite_value);//(model);//("", "", "", "");
	}

	@Override
	public void MyTieZi(String uid) {

		
		IAddGoods<GoodsListModel> addGoods = new AddGoodsRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(Mytiezi_success);
						AddGoodsPresenter.this.setChanged();
						AddGoodsPresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(Mytiezi_fail);
						AddGoodsPresenter.this.setChanged();
						AddGoodsPresenter.this.notifyObservers(result);

					}
				});
		addGoods.MyTieZi(uid);
	}

	

}
